import { KillEvilGetTaskItem } from "./KillEvilGetTaskItem";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { ColorConfig } from "../../resource/ColorConfig";
import { EColor } from "../../../../Message/Public/EColor";
import { GTextFormat } from "../../../common/GTextFormat";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { EKillEvilType } from "../../../../Message/Game/EKillEvilType";
import { GameConst } from "../../../component/gconst/GameConst";
import { GameProxy } from "../../mvc/GameProxy";
import { DataEvent } from "../../events/DataEvent";
import { GModuleEvent } from "../../mvc/GModuleEvent";
import { Cache } from "../../cache/Cache";
import { ETaskGroup } from "../../../../Message/Game/ETaskGroup";
import { ETaskStatus } from "../../../../Message/Game/ETaskStatus";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { GButton } from "../../../../com/mui/controls/GButton";
import { Vector } from "../../../../__AS3__/vec/Vector";
type int = number;
//class KillEvilTaskListPanel
    
    export  class KillEvilTaskListPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._getTaskItems = new Vector.<KillEvilGetTaskItem>();
            this.createChildren();
            this.addListeners();
            return;
        }

        protected createChildren(): void
        {
            ObjCreate.createBg(0, 0, 548, 266, this);
            ObjCreate.createBg(0, 271, 548, 120, this);
            ObjCreate.createBg(0, 56, 548, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(0, 354, 548, 2, this, ImagesConst.SplitLine);
            var loc1=HTMLUtil.addColor(Language.getString(90164), ColorConfig.instance.getItemColor(EColor._EColorOrange).color) + Language.getString(90165) + HTMLUtil.addColor(Language.getString(90166), ColorConfig.instance.getItemColor(EColor._EColorGreen).color) + "、" + HTMLUtil.addColor(Language.getString(90167), ColorConfig.instance.getItemColor(EColor._EColorBlue).color) + "、" + HTMLUtil.addColor(Language.getString(90168), ColorConfig.instance.getItemColor(EColor._EColorPurple).color) + "、" + HTMLUtil.addColor(Language.getString(90169), ColorConfig.instance.getItemColor(EColor._EColorOrange).color) + Language.getString(90170);
            var loc2=ObjCreate.createGTextField("", 5, 8, 520, 50, this, new GTextFormat(null, null, GlobalStyle.color1Uint, null, null, null, null, null, null, 10, 0, 25, 5));
            loc2.filters = [FilterConst.glowFilter];
            loc2.wordWrap = true;
            loc2.htmlText = loc1;
            this._getTaskItemGreen = this.createPropItem(43, 73, EKillEvilType._EKillEvilTypeHuman);
            this._getTaskItemBlue = this.createPropItem(173, 73, EKillEvilType._EkillEvilTypeEarth);
            this._getTaskItemPurple = this.createPropItem(303, 73, EKillEvilType._EkillEvilTypeHeaven);
            this._getTaskItemOrange = this.createPropItem(433, 73, EKillEvilType._EkillEvilTypeGod);
            ObjCreate.createLabel(Language.getString(90171), 5, 280, 150, 20, flash.text.TextFormatAlign.LEFT, this, true, 16777181);
            this._propOwnLabelGreen = ObjCreate.createLabel(Language.getString(90172), 28, 300, 330, 20, flash.text.TextFormatAlign.LEFT, this, true, ColorConfig.instance.getItemColor(EColor._EColorGreen).intColor);
            this._propOwnLabelBlue = ObjCreate.createLabel(Language.getString(90173), 258, 300, 330, 20, flash.text.TextFormatAlign.LEFT, this, true, ColorConfig.instance.getItemColor(EColor._EColorBlue).intColor);
            this._propOwnLabelPurple = ObjCreate.createLabel(Language.getString(90174), 28, 318, 330, 20, flash.text.TextFormatAlign.LEFT, this, true, ColorConfig.instance.getItemColor(EColor._EColorPurple).intColor);
            this._propOwnLabelOrange = ObjCreate.createLabel(Language.getString(90175), 258, 318, 330, 20, flash.text.TextFormatAlign.LEFT, this, true, ColorConfig.instance.getItemColor(EColor._EColorOrange).intColor);
            var loc3=GameConst.GetKillEvilTaskTime_start < 10 ? "0" + GameConst.GetKillEvilTaskTime_start : "" + GameConst.GetKillEvilTaskTime_start;
            var loc4=GameConst.GetKillEvilTaskTime_end < 10 ? "0" + GameConst.GetKillEvilTaskTime_end : "" + GameConst.GetKillEvilTaskTime_end;
            ObjCreate.createLabel(Language.getString(90176) + loc3 + "：30 - " + loc4 + "：30", 150, 366, 548, 20, flash.text.TextFormatAlign.LEFT, this, true, GlobalStyle.color1Uint);
            this._remainTimesLabel = ObjCreate.createLabel(Language.getString(90177), 5, 366, 200, 20, flash.text.TextFormatAlign.LEFT, this, false, GlobalStyle.color1Uint);
            this._refreshBtn = ObjCreate.createGButton(Language.getString(90178), 350, 360, 50, 26, this, "ButtonSpecial");
            this._publishKillEvilTaskBtn = ObjCreate.createGButton(Language.getString(90179), 410, 360, 126, 26, this, "ButtonSpecial");
            this._commitTaskBtn = ObjCreate.createGButton(Language.getString(90180), 410, 360, 126, 26, this, "ButtonSpecial");
            this._commitTaskBtn.visible = false;
            return;
        }

        protected addListeners(): void
        {
            this._refreshBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._publishKillEvilTaskBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._commitTaskBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            return;
        }

        /* internal  */createPropItem(arg1: int, arg2: int, arg3: int): KillEvilGetTaskItem
        {
            var loc1;
            (loc1 = new KillEvilGetTaskItem(arg3)).x = arg1;
            loc1.y = arg2;
            this.addChild(loc1);
            this._getTaskItems.push(loc1);
            return loc1;
        }

        /* internal  */onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target;
            switch (loc1) 
            {
                case this._refreshBtn:
                {
                    GameProxy.killEvilTask.KillEvilCanGetInfo();
                    break;
                }
                case this._publishKillEvilTaskBtn:
                {
                    this.dispatchEvent(new DataEvent(GModuleEvent.KillEvilTaskChangeCurrentPanel, 0, false, true, true));
                    break;
                }
                case this._commitTaskBtn:
                {
                    this.dispatchEvent(new DataEvent(GModuleEvent.KillEvilTaskCommit, null, false, true, true));
                    break;
                }
            }
            return;
        }

        public updateCanGetInfo(): void
        {
            var loc1=0;
            while (loc1 < this._getTaskItems.length) 
            {
                this._getTaskItems[loc1].updateCanGetInfo();
                ++loc1;
            }
            return;
        }

        public updateHadGetInfo(): void
        {
            var loc1=Cache.instance.killEvilTask.myGetInfo;
            if (loc1 == null) 
            {
                return;
            }
            var loc2=loc1.getHuman > 0 ? Language.getString(90181) : "";
            var loc3=loc1.getEarth > 0 ? Language.getString(90181) : "";
            var loc4=loc1.getHeaven > 0 ? Language.getString(90181) : "";
            var loc5=loc1.getGod > 0 ? Language.getString(90181) : "";
            var loc8=loc1.executeKillEvilType;
            switch (loc8) 
            {
                case EKillEvilType._EKillEvilTypeHuman:
                {
                    loc2 = Language.getString(90182);
                    break;
                }
                case EKillEvilType._EkillEvilTypeEarth:
                {
                    loc3 = Language.getString(90182);
                    break;
                }
                case EKillEvilType._EkillEvilTypeHeaven:
                {
                    loc4 = Language.getString(90182);
                    break;
                }
                case EKillEvilType._EkillEvilTypeGod:
                {
                    loc5 = Language.getString(90182);
                    break;
                }
            }
            this._propOwnLabelGreen.htmlText = Language.getStringByParam(90183, loc1.getHuman.toString(), loc2.toString());
            this._propOwnLabelBlue.htmlText = Language.getStringByParam(90184, loc1.getEarth.toString(), loc3.toString());
            this._propOwnLabelPurple.htmlText = Language.getStringByParam(90185, loc1.getHeaven.toString(), loc4.toString());
            this._propOwnLabelOrange.htmlText = Language.getStringByParam(90186, loc1.getGod.toString(), loc5.toString());
            this._remainTimesLabel.htmlText = Language.getStringByParam(90187, loc1.canGetCount.toString());
            var loc6=Cache.instance.task.getTaskByGroup(ETaskGroup._ETaskGroupKillEvil, ETaskStatus._ETaskStatusNotCompleted);
            var loc7=0;
            while (loc7 < this._getTaskItems.length) 
            {
                this._getTaskItems[loc7].updateHadGetInfo(loc1, loc6.length > 0);
                ++loc7;
            }
            if ((loc6 = Cache.instance.task.getTaskByGroup(ETaskGroup._ETaskGroupKillEvil, ETaskStatus._ETaskStatusHadCompleted)).length > 0) 
            {
                this._commitTaskBtn.visible = true;
                this._publishKillEvilTaskBtn.visible = false;
            }
            else 
            {
                this._commitTaskBtn.visible = false;
                this._publishKillEvilTaskBtn.visible = true;
            }
            return;
        }

        /* internal */ /* var */_getTaskItems: Vector.<KillEvilGetTaskItem>;

        /* internal */ /* var */_getTaskItemGreen: KillEvilGetTaskItem;

        /* internal */ /* var */_getTaskItemBlue: KillEvilGetTaskItem;

        /* internal */ /* var */_getTaskItemPurple: KillEvilGetTaskItem;

        /* internal */ /* var */_getTaskItemOrange: KillEvilGetTaskItem;

        /* internal */ /* var */_propOwnLabelGreen: GLabel;

        /* internal */ /* var */_propOwnLabelBlue: GLabel;

        /* internal */ /* var */_propOwnLabelPurple: GLabel;

        /* internal */ /* var */_propOwnLabelOrange: GLabel;

        /* internal */ /* var */_remainTimesLabel: GLabel;

        /* internal */ /* var */_refreshBtn: GButton;

        /* internal */ /* var */_publishKillEvilTaskBtn: GButton;

        /* internal */ /* var */_commitTaskBtn: GButton;
    }
